<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>区域合作申请</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
    <link rel="stylesheet" href="RegionalApplication.css">
    <script src="../src/static/jquery.js"></script>
    <script src="../layui/layui.js"></script>
</head>
<body>
<form class="layui-form" action="/api/getApplyAreaMst" method="post" style="margin-right: 10%;margin-top: 10%">
    <div class="layui-form-item">
        <label class="layui-form-label">公司名称</label>
        <div class="layui-input-block">
            <input type="text" name="companyName" required lay-verify="required" id="companyName"
                   placeholder="请输入公司名称/个人名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">您的姓名</label>
        <div class="layui-input-block">
            <input type="text" name="linkman" required lay-verify="required" id="linkman"
                   placeholder="请输入您的姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">您的电话</label>
        <div class="layui-input-block">
            <input type="text" name="phone" required lay-verify="required" id="phone"
                   placeholder="请输入您的电话" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">区域/街道</label>
        <div class="layui-input-block">
            <textarea name="areaAddress" required lay-verify="required" placeholder="您的业务主要集中在哪个区、街道"
                      class="layui-textarea" id="areaAddress"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">从业背景</label>
        <div class="layui-input-block">
            <select name="context" required lay-verify="required" id="context">
                <option value=""></option>
                <option value="0">大健康相关行业</option>
                <option value="1">网络科技相关行业</option>
                <option value="2">人工智能数码行业</option>
                <option value="3">快消品销售</option>
                <option value="4">传统销售</option>
                <option value="5">互联网地推</option>
                <option value="6">个人创业</option>
                <option value="7">公司成立新项目</option>
                <option value="8">其他</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">团队人数</label>
        <div class="layui-input-block">
            <input type="text" name="memberCount" required lay-verify="required" id="memberCount"
                   placeholder="请输入直营团队人数" autocomplete="off" class="layui-input">
        </div>
    </div>
    `
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">留言</label>
        <div class="layui-input-block">
        <textarea name="applyReason" placeholder="说说您申请的理由吧，例如：“我要拯救世界”、“我要改变历史”。。。"
                  class="layui-textarea" required lay-verify="required" id="applyReason"></textarea>
        </div>
    </div>
    <!--<div style="width: 100%;text-align: center">-->
    <!--<input type="submit" class="layui-btn" id="tijiao">-->
    <!--</div>-->
</form>
<div style="width: 100%;text-align: center">
    <button class="layui-btn" type="submit" id="tijiao">确认提交</button>
</div>

<script>
    //Demo
    layui.use('form', function () {
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function (data) {
            layer.msg(JSON.stringify(data.field));
            return false;
        });
    });
    //申请理由非空验证
    $('#areaAddress').click(function () {
        var phone = document.getElementById('phone').value;
        if (!(/^1[34578]\d{9}$/.test(phone))) {
            alert("手机号码有误，请重填");
            return false;
        }
    });
    $('#tijiao').click(function () {
        var phone = $('#phone').val();
        var companyName = $('#companyName').val();
        var applyReason = $('#applyReason').val();
        var memberCount = $('#memberCount').val();
        var context = $('#context').val();
        var linkman = $('#linkman').val();
        var areaAddress = $('#areaAddress').val();
        $.ajax({
            url: '/api/getApplyAreaMst',
            type: 'POST',
            data: {
                //手机
                phone: phone,
                //公司名称
                companyName: companyName,
                //申请理由
                applyReason: applyReason,
                //人数
                memberCount: memberCount,
                //从业背景
                context: context,
                //您的姓名
                linkman: linkman,
                //业务资源
                areaAddress: areaAddress
            },
            dataType: 'json',
            success: function (data) {
                alert(data.msg);
                window.location.reload();
            },
            error: function (error) {
                //请求失败  获取的报错信息
                console.log(error);
            }
        });
    })

</script>
</body>
</html>